﻿
// png
function setPng24(obj) {
  obj.width = obj.height=1;
  obj.className = obj.className.replace(/\bpng24\b/i,'');
  obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+obj.src+"',sizingMethod='image');"
  obj.src = ''; 
  return '';
}

(function($)
{
    if ( !$.Coffine ) {
        $.Coffine = {};
    };
    
    if ( !$.Cookie ) {
        $.Cookie = {};
    };
    
   
    $.Cookie = {
		Domain : "www.coffine.co.kr",
		
		SetCookie_Oneday : function( name, value )
		{
			$.Cookie.SetCookie_Dayout( name, value, 1 );
		},
		
		SetCookie_Dayout : function( name, value, day )
		{
			day = +day;

			if (!day || day <= 0) {
				day = 1;
			}
			var dateNow = new Date();
			var dateCalc = new Date(dateNow.getTime() + ( 24 * 60 * 60 * 1000 * day ) );
			$.Cookie.CreateCookie( name, value, dateCalc.toUTCString() );
		},
		
		SetCookie : function( name, value )
		{
			$.Cookie.CreateCookie( name, value, null );
		},
		
		CreateCookie : function( name, value, time )
		{
			document.cookie = name + "=" + escape(value) + "; path=/; domain=" + $.Cookie.Domain + ";" + ( time == null ? "" : ( "expires=" + time + ";" ) );
		},
		
		GetCookie : function( name )
		{
			var arrCookie = $.Cookie.ToString().split( ";" );

			for ( var i = 0; i < arrCookie.length; i ++ )
			{
				var arrData = arrCookie[ i ].split( "=" );
				
				if ( arrData.length == 2 )
				{
					if ( $.trim( arrData[ 0 ] ) == $.trim( name ) )
					{
						return $.trim( arrData[ 1 ] );
					}
				}
			}

			return "";
		},
		
		ToString : function()
		{
			var value = document.cookie;
			return value;
		}
    };

    $.Coffine = {
        Login : function(UserID, UserPWD, Redirect) {
            
            if ( $.trim( UserID ) == "" ) {
                alert( "아이디를 입력하세요" );
                return false;
            }
            
            if ( $.trim( UserPWD ) == "" ) {
                alert( "비밀번호를 입력하세요" );
                return false;
            }
            
            if (Redirect == undefined)
                Redirect = window.location.href;

            $("#frmLogin").empty().append( $("<input type='hidden' name='UserID' class='m_UserID' /><input type='password' name='UserPWD' class='m_UserPWD' style='display:none' /><input type='hidden' name='Redirect' class='m_Redirect' />" ));            
            $("#frmLogin>input.m_UserID").val( UserID );
            $("#frmLogin>input.m_UserPWD").val( UserPWD );
            $("#frmLogin>input.m_Redirect").val( Redirect );
            
            $("#frmLogin").attr({ "method":"post", "action":"/login/loginproc.aspx"});
            $("#frmLogin").submit();
        },
        
        Logout : function( Redirect ) {
			if (Redirect == undefined)
                Redirect = window.location.href;
			$("#frmLogin").empty().append( $("<input type='hidden' name='Redirect' class='m_Redirect' />" ));
			$("#frmLogin>input.m_Redirect").val( Redirect );
			$("#frmLogin").attr({ "method":"post", "action":"/login/logoutproc.aspx"});
            $("#frmLogin").submit();        
        },
        
        terms : function() {
			window.open( "/popup/pop_terms.aspx", "terms", "width=800, height=800,toolbar=no,menubar=no,location=no, scrollbars=no, status=no, resizable=no");
        },
        
        privacypolicy : function() {
			window.open( "/popup/pop_privacypolicy.aspx", "terms", "width=800, height=800,toolbar=no,menubar=no,location=no, scrollbars=no, status=no, resizable=no");
        },
        
        searchid : function() {
			window.open( "/popup/pop_idsearch.aspx", "idsearch", "width=400, height=300,toolbar=no,menubar=no,location=no, scrollbars=no, status=no, resizable=no");
        },
        
        searchpwd : function() {
			window.open( "/popup/pop_pwsearch.aspx", "pwsearch", "width=400, height=330,toolbar=no,menubar=no,location=no, scrollbars=no, status=no, resizable=no");
        },
        
        postopen : function(callback) {
			window.open("/popup/pop_address.aspx?callback=" + callback, "addrsearch", "width=420, height=500, scrollbars=1");
        },
        
        isEngNumber : function(val)
        {
			var check = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_01234567890.";
			var len = val.length;
			for( var i = 0; i < len; i ++ )
			{
				if ( check.indexOf( val.charAt( i ) ) == -1 )
				{
					return false;
				}
			}
			return true;
        },
        
        isEnglish : function(val) {
			var check = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
			var len = val.length;
			for( var i = 0; i < len; i ++ )
			{
				if ( check.indexOf( val.charAt( i ) ) == -1 )
				{
					return false;
				}
			}
			return true;
        },
        
        isNumber : function(val) {
			var check = "01234567890";
			var len = val.length;
			for( var i = 0; i < len; i ++ )
			{
				if ( check.indexOf( val.charAt( i ) ) == -1 )
				{
					return false;
				}
			}
			return true;
        },
        
        Ver : "1.0"
    };
})(jQuery);